#ifndef __EXTIO_DEV_H__
#define __EXTIO_DEV_H__

#include "board.h"
#include "../ext_io/pca9557.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    EXT_IO_MODE_OUTPUT,
    EXT_IO_MODE_INPUT
} ext_io_mode_t;

struct extio_driver_api {
    int (*exio_config)(struct device* dev, uint8_t gpio_bit, uint8_t mode);
    int (*exio_set_level)(struct device* dev, uint8_t gpio_bit, uint8_t level);
    int (*exio_get_level)(struct device* dev, uint8_t gpio_bit, uint8_t* level);
};

static inline int exio_config(struct device* dev, uint8_t gpio_bit, uint8_t mode)
{
    const struct extio_driver_api *api = dev->driver_api;

    return api->exio_config(dev, gpio_bit, mode);
}

static inline int exio_set_level(struct device* dev, uint8_t gpio_bit, uint8_t level)
{
    const struct extio_driver_api *api = dev->driver_api;

    return api->exio_set_level(dev, gpio_bit, level);
}

static inline int exio_get_level(struct device* dev, uint8_t gpio_bit, uint8_t* level)
{
    const struct extio_driver_api *api = dev->driver_api;

    return api->exio_get_level(dev, gpio_bit, level);
}

#ifdef __cplusplus
}
#endif

#endif /* __EXTIO_DEV_H__ */
